# Contributor: Timo Teras <timo.teras@iki.fi>
# Maintainer: Timo Teras <timo.teras@iki.fi>
pkgname=dahdi-tools
pkgver=3.1.0
pkgrel=1
pkgdesc="Digium Asterisk Hardware Device Interface management utilities"
url="https://www.asterisk.org"
arch="all"
license="GPL-2.0-or-later"
depends_dev="bsd-compat-headers linux-headers dahdi-linux-dev newt-dev"
makedepends="perl file autoconf automake libtool $depends_dev"
subpackages="$pkgname-doc $pkgname-dev"
source="http://downloads.digium.com/pub/telephony/dahdi-tools/releases/dahdi-tools-$pkgver.tar.gz
	fix-musl.patch
	$pkgname.initd
	"

prepare() {
	default_prepare
	autoreconf -fi
}


build() {
	eval local $(perl -V:vendorlib)
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/infoa \
		--with-perllib="$vendorlib"
	sed -i -e 's/$(CC) $(LDFLAGS) -o $@ $^/$(CC) $^ $(LDFLAGS) -o $@/' \
		Makefile
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/dahdi
	rm -rf "$pkgdir"/usr/lib/dracut # We use mkinitfs, not dracut
}

sha512sums="e0e5bf24e4834ca39ef7dc1af1bb7ef26bd258a8b2cb2406a7e1ffed25b4b1d44a5fce41d97c5ad7fc6ebb66f965759d2b49ffa6d89845786f43eadb89ff4694  dahdi-tools-3.1.0.tar.gz
45955caf04368ff30d60db0b3e892d940c9ac0422b337186ed251108ce25ab305d4590efff452f53f160a53fcd26a273f21d6d093307b426a3a2a6df53584daa  fix-musl.patch
3850ab9e323ec31d676d311c97d0cde70b809379b6c01c8ff6d5a01a860eb43bf3f18f2de53e952365d17f40638c7cb0481682d96cea5b7fdb1423d3e762e2f3  dahdi-tools.initd"
